/*
 * Copyright (c) 2015-2019 广东口袋零钱信息技术有限公司 All Rights Reserved.
 */

package com.hxh.exception.handler.utils;


import com.hxh.exception.handler.vo.ResultVO;


public class ResultUtil {

    /**
     * 成功
     */
    private static final String SUCCESS = "00";

    /**
     * 失败
     */
    private static final String FAILURE = "-1";

    /**
     * 私有化工具类 防止被实例化
     * j
     */
    private ResultUtil() {
    }

    /**
     * 成功
     *
     * @return 返回空
     */
    public static ResultVO success() {
        return success(null);
    }

    /**
     * 成功
     *
     * @param object 需要返回的数据
     * @return data
     */
    public static ResultVO success(Object object) {
        ResultVO result = new ResultVO();
        result.setCode(SUCCESS);
        result.setMessage("操作成功");
        result.setData(object);
        return result;
    }

    /**
     * 错误
     *
     * @param code 状态码
     * @param msg  消息
     * @return ResultVO
     */
    public static ResultVO error(String code, String msg) {
        ResultVO result = new ResultVO();
        result.setCode(code);
        result.setMessage(msg);
        return result;
    }

    /**
     * 错误
     *
     * @param msg 错误信息
     * @return ResultVO
     */
    public static ResultVO error(String msg) {
        return error(FAILURE, msg);
    }

}
